<?php
include 'design.php';
?>
<div class="inhalt"> 

<?php

$nutzer_back = $_SESSION['username'];
$pk = $_POST['aktivitaetsnr'];

//Übernahme vom Menü
if (!$link = mysql_connect ('localhost', 'dennis', 'dennis'))
{
	echo "Keine Verbindung zu mysql";
	
}
if (!mysql_select_db('dennis_schuelerdaten', $link))
{
	echo "konnte Datenbank nicht finden";
}

else
{

//Name der Aktivtät
$sql="SELECT Vorname, Name, Klasse, Email FROM Schueler WHERE AktivitaetsNr = $pk ";

mysql_query("SET NAMES 'utf8'");

	//SQL-Befehl senden
	$result = mysql_query($sql,$link);
	
	
	// Erste Zeile holen
	echo "<table border=3 width=100% >";
	echo "<tr>";
	echo "<th> Name </th>";
    echo "<th> Vorname </th>"; 
    echo "<th> Klasse </th>";
    echo "</tr>";
		
	
	
	$row= mysql_fetch_assoc($result);
	while ($row != NULL)
	   {
	   
	
	   echo "<tr><td>";
	   echo "".$row['Name'];
	   echo "</td>";
	   echo "<td>";
	   echo "".$row['Vorname'];
	   echo "</td>";
	   echo "<td>";
	   echo "".$row['Klasse'];
	   echo "</td>";
	   echo "</tr>";
	    
	  // naechste Zeile holen
		$row= mysql_fetch_assoc($result);
			
	  } 
	 
	  	  
	  $sql2="SELECT Vorname, Name, Klasse, Email FROM Schueler WHERE AktivitaetsNr = $pk ";
      mysql_query("SET NAMES 'utf8'");
	  $result2 = mysql_query($sql2,$link);  
	  $row2= mysql_fetch_assoc($result2);
	   echo "</table>";
	   echo "<br>E-Mail Adressen aller teilnehmenden SchÃ¼ler:<br>";
	
	   while ($row2!= NULL)
	   
	   {
		   echo"".$row2['Email'];
		   echo ",";
		   $row2= mysql_fetch_assoc($result2);
	  	   }
	   
         
	  }
?>
</div>
</body>
</html>
	